class Age implements Cloneable{
    int a;
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Student implements Cloneable{
    String name;
    Age age = new Age();
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Student student = (Student)super.clone();
        student.age = (Age)age.clone();
        return student;
    }
}
class WorkDesk {
    public static void main(String[] args) throws CloneNotSupportedException{
        Student student1 = new Student();
        student1.name = "You Know Who";
        Student student2 = (Student) student1.clone();//此时student1.clone返回的是一个父类——Object类
        System.out.println(student1.name);
        System.out.println(student2.name);
        student2.name = "Fuck You!!!";//student2.name的修改没有改变student1.name的值，说明Objective.clone()是深克隆
        System.out.println(student1.name);
        System.out.println(student2.name);
        student1.age.a = 8;
        System.out.println(student1.age.a);
        System.out.println(student2.age.a);
        student2.age.a = 20;
        System.out.println(student1.age.a);
        System.out.println(student2.age.a);
    }
}
